package cn.qzbook.dao.ManyToMany;


import cn.qzbook.MybatisTool;
import cn.qzbook.domain.Teacher;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class TeacherDao {

    private SqlSession sqlSession = MybatisTool.sqlSessionFactory().openSession(true);

    @Test
    public void test(){
        TeacherDao dao = new TeacherDao();
//        dao.selectTeacherAndInnerStu(2);
        dao.selectTeacherAndInnerStuList();
    }

    //给定老师的tid     -- > 查询老师的信息	+	选了当前老师课程的学生
    public void selectTeacherAndInnerStu(int id){
        Teacher teacher  = sqlSession.selectOne("selectTeacherAndInnerStu", id);
        System.out.println(teacher);
    }

    //查询所有老师的信息   +  选了当前老师课程的所有学生
    public void selectTeacherAndInnerStuList(){
        List<Teacher> teachers = sqlSession.selectList("selectTeacherAndInnerStuList");
        for (Teacher teacher : teachers){
            System.out.println(teacher);
        }
    }

}
